/**
 * 
 */

package com.chengyu.eyc.config;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.chengyu.eyc.interceptor.EycWechatHandlerInterceptor;
import com.chengyu.eyc.interceptor.EycWechatRegisterHandlerInterceptor;

/**
 * @author kevin
 *
 */
@Configuration
public class EycWeChatMvcConfigurer implements WebMvcConfigurer {

    private static final List<String> EXCLUDE_PATH_PATTERNS=Arrays.asList("/wechat/baseConfig/**","/wechat/isLogin","/wechat/genQRCode","/wechat/insertUser","/wechat/incoming","/wechat/getOpenId","/wechat/decryptData","/wechat/obtainVerifyCode","/wechat/verificationOrder","/wechat/pay/**","/wechat/obtainMiniUserInfo","/wechat/obtainOfficialAccountUserInfo","/wechat/il5AIHBIL9.txt");
    
    @Autowired
    private EycWechatHandlerInterceptor eycWechatHandlerInterceptor;

    @Autowired
    private EycWechatRegisterHandlerInterceptor eycWechatRegisterHandlerInterceptor;

    /**
     * @see org.springframework.web.servlet.config.annotation.WebMvcConfigurer#addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry)
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(eycWechatHandlerInterceptor).addPathPatterns("/wechat/**").excludePathPatterns(EXCLUDE_PATH_PATTERNS);
        registry.addInterceptor(eycWechatRegisterHandlerInterceptor).addPathPatterns("/wechat/insertUser");
    }

}
